package com.tch.service;


import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

/**
 *  全局捕获异常类
 */
@ControllerAdvice
public class MenExceptionHandler {
    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public HashMap<Object, Object> exceptionHandler(){
        HashMap<Object, Object> result = new HashMap<>();
        result.put("code","500");
        result.put("msg","系统错误");
        return result;
    }

    /**
     *  @ResponseBody -有这个注释时返回为json , 没有时返回页面(自己定义)
     */
}
